/*
 * WidgetClickeableWithText.cpp
 *
 *  Created on: Apr 21, 2012
 *      Author: gonzalo
 */

#include "WidgetClickeableWithText.h"

WidgetClickeableWithText::WidgetClickeableWithText(std::string text,Color color,int width,
		int height,int posX, int posY, Widget* parent):
WidgetClickeable(color,width,height,posX,posY,parent){

	if (text == STRING_EMPTY) {
		return;
	}

	this->text = text;
	this->textSurface = SurfaceUtils::renderText(text);

}


WidgetClickeableWithText::WidgetClickeableWithText(std::string text,std::string path,int posX, int posY, Widget* parent):
WidgetClickeable(path,posX,posY,parent){

	if (text == STRING_EMPTY) {
		return;
	}

	this->text = text;
	this->textSurface = SurfaceUtils::renderText(text);

}

void WidgetClickeableWithText::resolve(){

	//TODO ACA FALTA ALGO SIN DUDAS>..
}

void WidgetClickeableWithText::showOn(SDL_Surface* surface) {

	SDL_Rect textRect;
	textRect.x = (this->parcel.width - textSurface->w) / 2;
	textRect.y = (this->parcel.height - textSurface->h) / 2;
	textRect.w = textSurface->w;
	textRect.h = textSurface->h;

	SDL_BlitSurface(this->textSurface, NULL, this->surface, &textRect);
}



WidgetClickeableWithText::~WidgetClickeableWithText() {
	if(this->textSurface != NULL)
		SDL_FreeSurface(this->textSurface);
}

